package com.edu.flink.batch;

import org.apache.flink.api.java.DataSet;
import org.apache.flink.api.java.ExecutionEnvironment;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * DateSet输入源
 * </p>
 *
 * @author jpge
 * @since 2024-04-03
 */
public class DataSetDemo {
    // 1. 从集合中创建DataSet
    // 2. 从文本文件中创建DateSet

    public static void main(String[] args) throws Exception {


        // 1. 设置执行环境
        ExecutionEnvironment executionEnvironment = ExecutionEnvironment.getExecutionEnvironment();

        // 2. 输入源
        List<String> list = new ArrayList<>();
        list.add("abc");
        list.add("def");
        // ...
        DataSet<String> dateSet = executionEnvironment.fromCollection(list);
        dateSet.print();


        DataSet<String> dataSetFile = executionEnvironment.readTextFile(System.getProperty("user.dir") + "/flink-demo/src/main/resources/test.txt");
        dataSetFile.print();
//        System.out.println(System.getProperty("user.dir"));
//        executionEnvironment.execute();
    }


}
